#region

using System.Drawing;
using System.Windows.Forms;

#endregion

namespace EditeurSyntaxiqueVocal.Intellisencs
{
    ///<summary>
    ///</summary>
    public class IntellisenceListBox : ListBox
    {
        private ImageList _ImageList;
        public Form ParantForm;

        ///<summary>
        ///</summary>
        public ImageList ImageList
        {
            get { return _ImageList; }
            set { _ImageList = value; }
        }

        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            IntellisenceItem oIntelliListItem;
            Rectangle oRectangle;
            Size oSize;

            base.OnDrawItem(e);

            try
            {
                oRectangle = e.Bounds;
                oSize = ImageList.ImageSize;
                e.DrawBackground();
                e.DrawFocusRectangle();
                oIntelliListItem = (IntellisenceItem) Items[e.Index];
                if (oIntelliListItem.IndexImage == -1)
                    e.Graphics.DrawString(oIntelliListItem.ToString(), e.Font, new SolidBrush(e.ForeColor),
                                          oRectangle.Left, oRectangle.Top);
                else
                {
                    ImageList.Draw(e.Graphics, oRectangle.Left, oRectangle.Top, oIntelliListItem.IndexImage);
                    e.Graphics.DrawString(oIntelliListItem.ToString(), e.Font, new SolidBrush(e.ForeColor),
                                          oRectangle.Left + oSize.Width, oRectangle.Top);
                }
            }
            catch
            {
            }
        }
    }
}